Skip to content

fix: prevent transitive ThisAssembly.Constants deps from copying assemblies to output#392

Merged
kzu merged 2 commits into
mainfrom
fix/389-transitive-dlls
Jun 24, 2026
Merged

fix: prevent transitive ThisAssembly.Constants deps from copying assemblies to output#392
kzu merged 2 commits into
mainfrom
fix/389-transitive-dlls

Conversation

@kzu

@kzu kzu commented Jun 24, 2026

Copy link
Copy Markdown
Member

Fixes #389

Problem

Assemblies from transitive dependencies of ThisAssembly.Constants (System.Runtime.CompilerServices.Unsafe.dll and System.Threading.Tasks.Extensions.dll) were being placed into the consumer project's build output folder, even when using the recommended PrivateAssets="all" on the GitInfo package reference (and even on modern .NET Framework targets like net472).

This started happening in 3.2.0 when GitInfo began depending on ThisAssembly.Constants to generate the ThisAssembly.Git.* constants.

Solution

  • Restrict the PackageReference to ThisAssembly.Constants (in the authoring .msbuildproj) to only build and analyzers assets.
  • Add PackageReference Update rules in buildTransitive and buildMultiTargeting targets to enforce PrivateAssets="all" IncludeAssets="build;analyzers" on ThisAssembly.Constants for all consumers of GitInfo.
  • This ensures the generator runs (so Git constants are still produced) without pulling in its runtime shim dependencies as CopyLocal assemblies.

The generated package dependency now declares the limited assets, and the update rules ensure enforcement.

Verified:

  • Clean bin/ output (no unwanted DLLs) on net472 repros, with and without PrivateAssets on GitInfo ref.
  • ThisAssembly.Git.* constants continue to generate and function correctly.

kzu added 2 commits June 24, 2026 16:23
…mblies to output

Fixes #389

The change ensures that the runtime assemblies brought in by
ThisAssembly.Constants (System.Runtime.CompilerServices.Unsafe.dll
and System.Threading.Tasks.Extensions.dll) are not copied into the
consumer's build output folder, by restricting the package reference
assets to build/analyzers only (and enforcing via buildTransitive).

- Updated authoring PackageReference
- Added PackageReference Update in buildTransitive + buildMultiTargeting
- Updated changelog
The bare 'dnx' command was not found in the pwsh-invoked test steps
in GHA (despite the dotnet-env setup), causing build job failures.
Using the explicit 'dotnet dnx' form (which the local env also exposes)
makes the test step robust across shells and runners.

This is incidental to the main fix but required to get green CI.
@kzu kzu merged commit 61efa7d into main Jun 24, 2026
4 checks passed
@kzu kzu deleted the fix/389-transitive-dlls branch June 24, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assemblies of transitive nuget dependencies are placed into the build folder

1 participant